package com.han.state.after;

/**
 * @ClassName Context
 * @Description 环境角色类
 * @Author duoduo Han
 * @Date 2024/6/16 12:27
 */
public class Context {
    //定义对应状态对象的常量
    public final static OpeningState OPENING_STATE = new OpeningState();
    public final static ClosingState CLOSING_STATE = new ClosingState();
    public final static RunningState RUNNING_STATE = new RunningState();
    public final static StoppningState STOPPING_STATE = new StoppningState();

    //定义一个当前电梯状态变量
    private LiftState liftState;

    //设置当前状态对象
    public void setLiftState(LiftState liftState) {
        this.liftState = liftState;
        //设置当前状态中的Context对象
        this.liftState.setContext(this);
    }
    public void open() {
        this.liftState.open();
    }
    public void close() {
        this.liftState.close();
    }
    public void run() {
        this.liftState.run();
    }
    public void stop() {
        this.liftState.stop();
    }
}
